﻿/* 2014/4/6 */
using System.IO;
using System.Collections.Generic;

namespace Cosmos.IO.FileSystemOperation
{
    /// <summary>
    /// Provides file system operations by invoking Windows API.
    /// </summary>
    public class WindowsFileSystemOperator : IFileSystemOperator
    {
        public void Rename(string srcFilePath, string dstFilePath)
        {
            if (!WindowsFileSystem.Rename(srcFilePath, dstFilePath))
                throw new IOException();
        }

        public void Move(string srcFilePath, string dstDirectoryPath)
        {
            if (!WindowsFileSystem.Move(srcFilePath, dstDirectoryPath))
                throw new IOException();
        }

        public void Move(IEnumerable<string> srcFilePaths, string dstDirectoryPath)
        {
            if (!WindowsFileSystem.Move(srcFilePaths, dstDirectoryPath))
                throw new IOException();
        }

        public void Copy(string srcFilePath, string dstDirectoryPath)
        {
            if (!WindowsFileSystem.Copy(srcFilePath, dstDirectoryPath))
                throw new IOException();
        }

        public void Copy(IEnumerable<string> srcFilePaths, string dstDirectoryPath)
        {
            if (!WindowsFileSystem.Copy(srcFilePaths, dstDirectoryPath))
                throw new IOException();
        }

        public void Delete(string srcFilePath)
        {
            if (!WindowsFileSystem.Delete(srcFilePath))
                throw new IOException();
        }

        public void Delete(IEnumerable<string> srcFilePaths)
        {
            if (!WindowsFileSystem.Delete(srcFilePaths))
                throw new IOException();
        }
    }
}
